Repository navigation
csdb: sync the BerkeleyDB log before a checkpoint is saved - #47
Merged
Merged
Conversation
BlockChain flushes the block storage before it saves a checkpoint, so that the checkpoint never gets ahead of the blocks on disk. The BerkeleyDB backend had no flush(): its commits run with DB_TXN_NOSYNC, so their log records can stay in the in-process log buffer. When the process was killed, the checkpoint survived but the last blocks did not, and the next start failed with "startSequence > last_seq_in_db + 1" and stopped the node. flush() now writes and syncs the log, once per checkpoint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BlockChain flushes the block storage before it saves a checkpoint, so that the checkpoint never gets ahead of the blocks on disk. The BerkeleyDB backend had no
flush()(the base class returns true): its commits run withDB_TXN_NOSYNC, so their log records can stay in the in-process log buffer.Found by the new
all-storage-power-cutscenario (every node killed at once): the BerkeleyDB pruned node had checkpoint qs/2506 but only blocks up to 2504 in the database, and its next start failed withstartSequence > last_seq_in_db + 1and stopped the node for good.flush()now callsDbEnv::log_flush(nullptr), which writes and syncs the log, once per checkpoint (about once a minute). With the fix,all-storage-power-cutandall-storage-crashpass (run 39018183898). No block or consensus change.🤖 Generated with Claude Code